package eteam.aps.controller;

import eteam.aps.common.R;
import eteam.aps.common.exceptions.AuthException;
import eteam.aps.common.helper.Helper;
import eteam.aps.model.vo.ParamFromWindowingVo;
import eteam.aps.model.vo.UserVo;
import eteam.aps.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户控制器
 *
 * @author WMT
 */
@Api(tags = "用户模块")
@RestController
public class UserController implements IUserController {

    @Autowired
    private UserService userService;

    @Override
    @ApiOperation("组织机构列表")
    @PostMapping("/user/orgList")
    public R<List<ParamFromWindowingVo>> orgList() throws Exception, AuthException {
        return R.success(userService.selectPfromSo());
    }

    @Override
    @ApiOperation("用户列表")
    @PostMapping("/user/userList")
    public R<List<UserVo>> userList(@RequestParam(value = "fullName",required = false) String fullName) throws Exception, AuthException {
        Map<String, Object> map = new HashMap<>();
        if (Helper.isNotEmpty(fullName)){
            map.put("fullName",Helper.likeSql(fullName));
        }
        return R.success(userService.selectAll(map));
    }
}
